<%@ include file = "/common/ini.jsp"%>
<%@ include file = "/common/_log4j.jsp"%>
<%@ include file = "/common/_ApplicationContext_init.jsp"%>
<%@ include file = "/common/_vr.jsp"%>
<%
    // 定义名称
    String title = "新增栏目";
    String remark = "";
%>
<script>
    function submitData()
    {
        selectAll(detailForm.tIds);
        selectAll(detailForm.tTypes);
        detailForm.serviceURL.value = "viewframe.column.NewColumnService";
        detailForm.submit();
    }
    function reset()
    {
        delAllOptions(detailForm.tIds);
        delAllOptions(detailForm.tTypes);
        <%
        if(vr.isAllValidated())
        {
            %>
            loadFrame1.location.href="<%= request.getContextPath()%>/moduleinfor/viewframe/column/_loadHomes.jsp";
            detailForm.code.value = "";
            detailForm.name.value = "";
            detailForm.imageUrl.value = "";
            detailForm.url.value = "";
            detailForm.remark.value = "";
            this.setLogo("");
            <%
        }
        else
        {
            String[] tIds = request.getParameterValues("tIds");
            String[] tTypes = request.getParameterValues("tTypes");
            if(tIds != null && tTypes != null)
            {
                OrgManager orgManager = (OrgManager)applicationContext.getBean("orgManager");
                RoleManager roleManager = (RoleManager)applicationContext.getBean("roleManager");
                PostManager postManager = (PostManager)applicationContext.getBean("postManager");
                for(int i = 0; i < tIds.length; i ++ )
                {
                    int type = Integer.parseInt(tTypes[i]);
                    switch(type)
                    {
                        case SysFrameParams.ORG : 
                        {
                            Org org = (Org)orgManager.get(tIds[i]);
                            %>
                            this.addOption(detailForm.tIds,"<%= org.getId()%>","<%= org.getName()%>" + " (ORG)");
                            this.addOption(detailForm.tTypes,"<%= tTypes[i]%>","<%= tTypes[i]%>");
                            <%
                            break;
                        }
                        case SysFrameParams.ROLE : 
                        {
                            Role role = (Role)roleManager.get(tIds[i]);
                            %>
                            this.addOption(detailForm.tIds,"<%= role.getId()%>","<%= role.getName()%>" + " (ROLE)");
                            this.addOption(detailForm.tTypes,"<%= tTypes[i]%>","<%= tTypes[i]%>");
                            <%
                            break;
                        }
                        case SysFrameParams.POST : 
                        {
                            Post post = (Post)postManager.get(tIds[i]);
                            %>
                            this.addOption(detailForm.tIds,"<%= post.getId()%>","<%= post.getName()%>" + " (POST)");
                            this.addOption(detailForm.tTypes,"<%= tTypes[i]%>","<%= tTypes[i]%>");
                            <%
                            break;
                        }
                        default:
                        {
                            throw new Exception("未知目标类型:" + type);
                        }
                    } // switch
                }//for
            } // if
            %>
            loadFrame1.location.href="<%= request.getContextPath()%>/moduleinfor/viewframe/column/_loadHomes.jsp?homeId=<%= request.getParameter("homeId")%>";
            loadFrame2.location.href="<%= request.getContextPath()%>/moduleinfor/viewframe/column/_loadAreas.jsp?homeId=<%= request.getParameter("homeId")%>&areaId=<%= request.getParameter("areaId")%>";
            loadFrame3.location.href="<%= request.getContextPath()%>/moduleinfor/viewframe/column/_loadColumns.jsp?areaId=<%= request.getParameter("areaId")%>&columnId=<%= request.getParameter("parentId")%>";
            detailForm.code.value = "<%= request.getParameter("code")%>";
            detailForm.name.value = "<%= request.getParameter("name")%>";
            detailForm.imageUrl.value = "<%= request.getParameter("imageUrl")%>";
            detailForm.url.value = "<%= request.getParameter("url")%>";
            this.setLogo("<%= request.getParameter("imageUrl")%>");
            <%
            remark = request.getParameter("remark");
        }
        %>
    }
</script>
<%@ include file = "/common/detail/_OnForm.jsp"%>
<%@ include file = "_detail.jsp"%>
<%@ include file = "/common/detail/_UnderForm.jsp"%>
